import {Col, message, Row, Statistic} from 'antd';
import React, {useEffect, useState} from 'react';
import {getCountAnalysisUsingGet} from "@/services/backend/analysisController";

const App: React.FC = () => {

  const [data, setData] = useState<API.CountAnalysisVO>();

  useEffect(() => {
    try {
      getCountAnalysisUsingGet().then(res => {
        if (res.data) {
          setData(res.data);
        }
      })
    } catch (e: any) {
      message.error("获取数据失败，请稍后重试."+e.message)
    }
  }, [])

  return (
    <Row gutter={16}>
      <Col span={12}>
        <Statistic title="总借阅量" value={data?.allBorrowCount} />
      </Col>
      <Col span={12}>
        <Statistic title="总图书量" value={data?.bookCount} />
      </Col>
      <Col span={12}>
        <Statistic title="未归还数量" value={data?.nowBorrowCount}  />
      </Col>
      <Col span={12}>
        <Statistic title="现图书种类" value={data?.bookIdCount}  />
      </Col>
    </Row>
  )
}

export default App;
